# eric7.EricWidgets.EricMessageBox

Module implementing QMessageBox replacements and more convenience function.

### Global Attributes

Abort
AcceptRole
ActionRole
Apply
ApplyRole
Cancel
Close
Critical
DestructiveRole
Discard
Help
HelpRole
Ignore
Information
InvalidRole
No
NoButton
NoIcon
NoRole
NoToAll
Ok
Open
Question
RejectRole
Reset
ResetRole
RestoreDefaults
Retry
Save
SaveAll
Warning
Yes
YesRole
YesToAll

### Classes

EricMessageBox | Class implementing a replacement for QMessageBox.

### Functions

__messageBox | Private module function to show a modal message box.
about | Function to show a modal dialog with some text about the application.
aboutQt | Function to show a modal dialog with text about Qt.
critical | Function to show a modal critical message box.
information | Function to show a modal information message box.
okToClearData | Function to show a modal message box to ask for clearing the data.
question | Function to show a modal question message box.
retryAbort | Function to show a model abort/retry message box.
warning | Function to show a modal warning message box.
yesNo | Function to show a model yes/no message box.

## EricMessageBox

Class implementing a replacement for QMessageBox.

### Derived from

QMessageBox

### Class Attributes

None

### Class Methods

None

### Methods

EricMessageBox | Constructor

### Static Methods

None

#### EricMessageBox (Constructor)

EricMessageBox(icon, title, text, modal=False, buttons=QMessageBox.StandardButton.NoButton, parent=None, )

Constructor

icon (QMessageBox.Icon)
  type of icon to be shown
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
modal (bool)
  flag indicating a modal dialog
buttons (StandardButtons)
  set of standard buttons to generate
parent (QWidget)
  parent widget of the message box

Up

## __messageBox

__messageBox(parent, title, text, icon, buttons=QMessageBox.StandardButton.Ok, defaultButton=QMessageBox.StandardButton.NoButton, textFormat=Qt.TextFormat.AutoText, )

Private module function to show a modal message box.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
icon (QMessageBox.Icon)
  type of icon to be shown
buttons (QMessageBox.StandardButtons)
  flags indicating which buttons to show
defaultButton (QMessageBox.StandardButton)
  flag indicating the default button
textFormat (Qt.TextFormat)
  format of the text

Return:
  button pressed by the user

Return Type:
  QMessageBox.StandardButton

Up

## about

about(parent, title, text)

Function to show a modal dialog with some text about the application.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box

Up

## aboutQt

aboutQt(parent, title="")

Function to show a modal dialog with text about Qt.

parent (QWidget)
  parent widget of the message box
title (str (optional))
  caption of the message box (defaults to "")

Up

## critical

critical(parent, title, text, buttons=QMessageBox.StandardButton.Ok, defaultButton=QMessageBox.StandardButton.NoButton, )

Function to show a modal critical message box.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
buttons (QMessageBox.StandardButtons)
  flags indicating which buttons to show
defaultButton (QMessageBox.StandardButton)
  flag indicating the default button

Return:
  button pressed by the user

Return Type:
  QMessageBox.StandardButton

Up

## information

information(parent, title, text, buttons=QMessageBox.StandardButton.Ok, defaultButton=QMessageBox.StandardButton.NoButton, )

Function to show a modal information message box.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
buttons (QMessageBox.StandardButtons)
  flags indicating which buttons to show
defaultButton (QMessageBox.StandardButton)
  flag indicating the default button

Return:
  button pressed by the user

Return Type:
  QMessageBox.StandardButton

Up

## okToClearData

okToClearData(parent, title, text, saveFunc, textFormat=Qt.TextFormat.AutoText)

Function to show a modal message box to ask for clearing the data.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
saveFunc (function)
  reference to a function performing the save action. It must be a parameterless function returning a flag indicating success.
textFormat (Qt.TextFormat)
  format of the text

Return:
  flag indicating that it is ok to clear the data

Return Type:
  bool

Up

## question

question(parent, title, text, buttons=QMessageBox.StandardButton.Ok, defaultButton=QMessageBox.StandardButton.NoButton, )

Function to show a modal question message box.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
buttons (QMessageBox.StandardButtons)
  flags indicating which buttons to show
defaultButton (QMessageBox.StandardButton)
  flag indicating the default button

Return:
  button pressed by the user

Return Type:
  QMessageBox.StandardButton

Up

## retryAbort

retryAbort(parent, title, text, icon=Question, textFormat=Qt.TextFormat.AutoText)

Function to show a model abort/retry message box.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
icon (QMessageBox.Icon)
  icon for the dialog (Critical, Information, Question or Warning)
textFormat (Qt.TextFormat)
  format of the text

Return:
  flag indicating the selection of the Retry button

Return Type:
  bool

Raises ValueError:
  raised to indicate a bad parameter value

Up

## warning

warning(parent, title, text, buttons=QMessageBox.StandardButton.Ok, defaultButton=QMessageBox.StandardButton.NoButton, )

Function to show a modal warning message box.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
buttons (QMessageBox.StandardButtons)
  flags indicating which buttons to show
defaultButton (QMessageBox.StandardButton)
  flag indicating the default button

Return:
  button pressed by the user

Return Type:
  QMessageBox.StandardButton

Up

## yesNo

yesNo(parent, title, text, icon=Question, yesDefault=False, textFormat=Qt.TextFormat.AutoText, )

Function to show a model yes/no message box.

parent (QWidget)
  parent widget of the message box
title (str)
  caption of the message box
text (str)
  text to be shown by the message box
icon (QMessageBox.Icon)
  icon for the dialog (Critical, Information, Question or Warning)
yesDefault (bool)
  flag indicating that the Yes button should be the default button
textFormat (Qt.TextFormat)
  format of the text

Return:
  flag indicating the selection of the Yes button

Return Type:
  bool

Raises ValueError:
  raised to indicate a bad parameter value

Up